package a.storeGenerator;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import ru.signalcom.util.encoders.Base64;

public class PrintCertRequestUtil {
	public static void main(String[] args) {
		try {
			getCode();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static void getCode() throws Exception{
		//File f = new File("C:\\Projects\\RKK\\testdata\\0001\\newreq.p10");
		byte[] newreq = fread("C:\\Projects\\RKK\\testdata\\0001\\newreq.p10");
		Base64 localEncoder = new Base64();
		byte[] encoded = localEncoder.encode(newreq); 
		String s = new String(encoded);		
		System.out.println(s);
	}
	
	private static byte[] fread(String fname) throws IOException {
		byte[] data = null;
		File file = new File(fname);
		FileInputStream stream = new FileInputStream(file);
		data = new byte[(int) file.length()];
		stream.read(data);
		stream.close();
		return data;
	}
}
